package com.sss.hloster0405;

public class InsertSort {// 插入排序
	public InsertSort(int a[]) {
		int temp = 0;
		for (int i = 0; i < a.length; i++) {
			int j;
			temp = a[i];
			for ( j = i - 1; j >= 0 && temp < a[j]; j--) {
				a[j + 1] = a[j];
			}
			a[j + 1] = temp;
		}
		System.out.println("插入排序后的数组顺序为：");
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + "   ");
		}
	}

}
